<!--
*@repayment-account
*@author lijiaqi
*@date 2023/12/21 10:16
-->
<template>
  <div class="weui-cell_access">
    <div class="weui-cell__ft vux-cell-primary">
      <van-field class="showValue" readonly clickable :value="value.code" placeholder="请选择" style="padding: 0;" @click="showPicker = true"/>
    </div>

    <van-popup v-model="showPicker" position="bottom" round :style="{ height: '40%' }">
      <van-nav-bar title="选择收款/还款账户" left-text="取消" @click-left="showPicker = false"></van-nav-bar>
      <div class="select-repayment-account">
        <div class="repayment-li" v-for="item in bankList" :key="item.id" @click="selectBank(item)">
          <div>
            <div class="repayment-icon" v-if="item.code != value.code">
              <van-icon name="card"/>
            </div>
            <van-icon v-else name="checked"/>
          </div>
          <div class="repayment-bank">
            <div>{{ item.code }}</div>
            <p>{{ item.name }}</p>
          </div>
        </div>
      </div>
    </van-popup>
  </div>
</template>

<script>
export default {
  name: "repayment-account",
  props: {},
  components: {},
  data() {
    return {
      value: '',
      showPicker: false,
      bankList: [
        {code: '6217******1793', name: 'XXXXXXXX农商银行'},
        {code: '6217******1231', name: 'XXXXXXXX农商银行'},
        {code: '6217******6786', name: 'XXXXXXXX农商银行'},
      ]
    }
  },
  computed: {},
  watch: {},
  created() {
  },
  mounted() {
  },
  methods: {
    // 选择还款账户
    selectBank(item) {
      this.value = item;
      this.showPicker = false;
      this.$emit('input', item.code)
    }
  }
}
</script>

<style lang="less" scoped>
.showValue {
  color: #000000;
  font-size: 17px;
}

.select-repayment-account {
  height: calc(~'100% - 6.8rem');
  border-top: 1px solid rgb(242, 242, 242);
  padding: 1.2rem 2rem;
  overflow: auto;

  .repayment-li {
    padding: 0.8rem 0;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(229, 230, 235, 0.5);

    .repayment-icon {
      width: 2.8rem;
      height: 2.8rem;
      border: 1px solid var(--primary-color);
      color: var(--primary-color);
      border-radius: 50%;
      margin-right: 1.6rem;
      display: flex;
      align-items: center;
      justify-content: center;

      /deep/ .van-icon {
        font-size: 1.8rem;
      }
    }

    /deep/ .van-icon {
      &.van-icon-checked {
        font-size: 3rem;
        color: var(--primary-color);
        margin-right: 1.6rem;
      }
    }

    .repayment-bank {
      width: calc(~'100% - 4.4rem');

      div {
        font-size: 1.6rem;
        line-height: 2.2rem;
        font-weight: 500;
      }

      p {
        font-size: 1.4rem;
        line-height: 2.2rem;
        color: rgba(29, 33, 41, 0.54);
      }
    }
  }
}
</style>
